package nl.project.dataImport;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import nl.project.data.Enrollment;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

public class AddShitLoadEnrollments extends HttpServlet {

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		ArrayList<Enrollment> enrollments = new ArrayList<Enrollment>();
		Enrollment enrol;
		
		double calc;
		
		ArrayList<String> contact = new ArrayList<String>();
		ArrayList<Boolean> prefDay = new ArrayList<Boolean>();
		ArrayList preferences = new ArrayList();
		
		for(int i = 0; i < 100; i++){
			enrol = new Enrollment();
			enrol.setStudentID(i);
			enrol.setParentID(i+23);
			contact.add("mail"+i+"@shithappened.org");
			contact.add("Straat "+i);
			contact.add("234"+i+"FD");
			contact.add("Stad numero "+i);
			calc = Math.pow(i, 9);
			contact.add(""+calc);
			enrol.setContact(contact);
			prefDay.add(true);
			prefDay.add(false);
			prefDay.add(false);
			
			preferences.add(prefDay);
			preferences.add("Later");
			
			enrol.setPreferences(preferences);
			//enrol.setTeacherID(i+98);
			
			contact.clear();
			prefDay.clear();
			preferences.clear();
			
		}
		DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
		Key enrollmentKey = KeyFactory.createKey("Enrollments", "Enrollments");
		Entity enrollmentsEntity = new Entity("Enrollment", enrollmentKey);
		enrollmentsEntity.setProperty("list", enrollments);
		ds.put(enrollmentsEntity);
		
		resp.getWriter().println("Shit Happened");
	}
}
